package mapreduce;

import java.nio.ByteBuffer;

public class BufferChecker {
	static public ByteBuffer check(ByteBuffer buffer, int appendSize){
		if(buffer.remaining() < appendSize){
			ByteBuffer newBuffer = ByteBuffer.allocate(buffer.capacity() * 2);
			newBuffer.put(buffer.array(), 0, buffer.position());
			buffer = null;
			return check(newBuffer, appendSize);
		}
		return buffer;
	}
}
